package com.ruoyi.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysGeographical;
import com.ruoyi.system.domain.SysMenu;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
public class TreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long key;
    private Long parentId;
    private String deptType;
    /** 节点名称 */
    private String title;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(SysDept dept)
    {
        this.key = dept.getDeptId();
        this.title = dept.getDeptShortName();
        this.parentId = dept.getParentId();
        this.deptType = dept.getDeptType();

        if (dept.getChildren() != null){
            this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        }

    }

    public TreeSelect(SysMenu menu)
    {
        this.key = menu.getMenuId();
        this.title = menu.getName();

        if (menu.getChildren() != null){
            this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        }

    }

    public TreeSelect(SysGeographical sysGeographical) {
        this.key = sysGeographical.getGeographicalId();
        this.title = sysGeographical.getGeographicalName();
        if (sysGeographical.getChildren() != null){
            this.children = sysGeographical.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        }
    }

    public Long getKey() {
        return key;
    }

    public void setKey(Long key) {
        this.key = key;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<TreeSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelect> children)
    {
        this.children = children;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getDeptType() {
        return deptType;
    }

    public void setDeptType(String deptType) {
        this.deptType = deptType;
    }
}
